package com.eascs.workflow.exception.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.workflow.common.entity.exception.JSErrorEntity;
import com.eascs.workflow.common.vo.ModelResult;
import com.eascs.workflow.exception.dao.CatchJSExceptionDao;
import com.eascs.workflow.exception.service.CatchJSExceptionInlet;

@Service
public class CatchJSExceptionInletImpl implements CatchJSExceptionInlet{
	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private CatchJSExceptionDao catchJSExceptionDao;
	
	@Override
	public ModelResult<Boolean> insert(JSErrorEntity jsError) {
		ModelResult<Boolean> modelResult = new ModelResult<>();
		try {
			int result=catchJSExceptionDao.insert(jsError);
			if (result > 0 ) {
				modelResult.withModel(true);
			}else{
				modelResult.withModel(false);
			}
		} catch (Exception e) {
			modelResult.withError("CatchJSExceptionImpl.insert", "js异常捕获失败");
			logger.error("js异常捕获失败,object：{},errMsg:{}", jsError.toString(), e.getMessage());
		}
		return modelResult;
	}

}
